package cn.tang.tframe.common.exception;

import java.io.Serializable;

/**
 * @author tanghc
 */
public class BaseRtmException extends RuntimeException implements Serializable {

	private static final long serialVersionUID = 1L;
	private String errorCode;
	private String messageForClient;

	public BaseRtmException(String errorCode, String message) {
		super(message);
		this.errorCode = errorCode;
	}

	public BaseRtmException(String errorCode, String message, String messageForClient) {
		super(message);
		this.errorCode = errorCode;
		this.messageForClient = messageForClient;
	}

	public BaseRtmException(String errorCode, String message, Throwable cause) {
		super(message, cause);
		this.errorCode = errorCode;
	}

	public BaseRtmException(String errorCode, String message, String messageForClient, Throwable cause) {
		super(message, cause);
		this.errorCode = errorCode;
		this.messageForClient = messageForClient;
	}

	public BaseRtmException(Exception e) {
		super(e);
	}

	public BaseRtmException(String message) {
		super(message);
	}

	public BaseRtmException(String message, Throwable cause) {
		super(message, cause);
	}

	@Override
	public String getMessage() {
		return super.getMessage();
	}

	public String getMessageForClient() {
		return messageForClient;
	}

	public String getErrorMessage() {
		String msg = getMessageForClient();
		if (null == msg || msg.trim().length() == 0) {
			msg = getMessage();
		}
		return msg;
	}

	public void setMessageForClient(String messageForClient) {
		this.messageForClient = messageForClient;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	@Override
	public String toString() {
		return "BaseCustomRtmException{" + "errorCode='" + errorCode + '\'' + ", message='" + getMessage() + '\''
				+ ", messageForClient='" + messageForClient + '\'' + '}';
	}
}